<script type="text/php">
    if ( isset($pdf) ) {

    // Open the object: all drawing commands will
    // go to the object instead of the current page
    $footer = $pdf->open_object();

    $w = $pdf->get_width();
    $h = $pdf->get_height();

    // Draw a line along the bottom
    $y = $h - 2 * $text_height - 24;
    $pdf->line(36, $y, $w - 36, $y, $color, 1);

    $pdf->page_text($w - 140, $y + 5, "Halaman {PAGE_NUM} dari {PAGE_COUNT}", $font, 10, array(0,0,0));
    $pdf->page_text($w - 220, 18, date("H:i:s d/m/Y")." dari AddPro", $font, 10, array(0,0,0));
    $img_w = 996; // 2 inches, in points
    $img_h = 370; // 1 inch, in points -- change these as required
    $pdf->image(base_url()."/assets/default/addprologotrans.png", "png", 20, $w, $img_h, $img_w);
    $pdf->image(base_url()."/assets/default/addprologotrans.png", "png", 385, $w, $img_h, $img_w);
    $pdf->image(base_url()."/assets/default/addprologotrans.png", "png", 750, $w, $img_h, $img_w);

    // Close the object (stop capture)
    $pdf->close_object();

    // Add the object to every page. You can
    // also specify "odd" or "even"
    $pdf->add_object($footer, "all");
    }
</script>
<style>
    @page { margin: 70px 50px; }
    body,h2,h3 {
        font-family: 'dotmatri';
    }
    body {
        font-size: 10px;
    }
    table.equalDevide tr td { width: 50%; }
</style>

<div style="width: 100%" align="center"><h3>History Stok <b><?= $barang['BARANG_NAMA'] ?> di <?= $tempat['TEMPAT_NAMA'] ?></b></h3></div>


<table class="table table-striped table-bordered table-hover" id="tabel_stok" style="">
    <thead>
        <tr>
            <th>No.</th>
            <th>Kode Transaksi</th>
            <th>Nama Transaksi</th>
            <th>Tanggal Transaksi</th>
            <th>Qty Masuk (<?= $barang['SATUAN_NAMA'] ?>)</th>
            <th>Qty Keluar (<?= $barang['SATUAN_NAMA'] ?>)</th>
            <th>Qty Awal (<?= $barang['SATUAN_NAMA'] ?>)</th>
            <th>Qty Akhir (<?= $barang['SATUAN_NAMA'] ?>)</th>
        </tr>
    </thead>
    <tbody class="" id="tabel_stok_body">
        <?php
        $c = 0;
        $stok = 0;
        $o_stok = 0;
        foreach ($history as $hsty) {
            $o_stok = $stok;
            $stok+= $hsty['QTY_MASUK'] - $hsty['QTY_KELUAR'];
            $c++;
            ?>
            <tr>
                <td><?= $c ?></td>
                <td><?= $hsty['KODE_TRANSAKSI'] ?></td>
                <td><?= $hsty['NAMA_TRANSAKSI'] ?></td>
                <td><?= $hsty['TANGGAL_TRANSAKSI'] ?></td>
                <td><?= $hsty['QTY_MASUK'] ?></td>
                <td><?= $hsty['QTY_KELUAR'] ?></td>
                <td><?= $o_stok ?></td>
                <td><?= $stok ?></td>
            </tr>
            <?php
        }
        ?>
    </tbody>
</table>
<style type="text/css">
    .centerTable tbody tr td{
        height: 10px;
    }
    .centerTable th{
        text-align: center;
        background-color: #0993D3;
        color: #FFFFFF;
        height: 15px;
        font-size: 15px;
    }
    .ket_po{
        background-color: #EEEEEE;
    }
</style>